package esc

import (
	"log"

	"github.com/olivere/elastic/v7"
)

// ES 客户端
var (
	esCli *elastic.Client
)

// GetESClient 获取 ES client
func GetESClient() *elastic.Client {
	if esCli != nil {
		return esCli
	}
	client, err := elastic.NewClient(elastic.SetURL("http://gin_es:9200"))
	if err != nil {
		log.Println("es 连接错误", err)
	} else {
		log.Println("elastic连接成功")
	}
	return client
}
